<template>
	<view class="st-content">
		<view class="st-main">
			<view class="st-main-stlist">
				<uni-card v-for="(item,index) in stList" :key="item.stId">
								<image slot='cover' style="width: 100%; margin-top: 10rpx; border-radius: 10rpx;" :src="item.stCoverImage" @click="toStdetail(item.stId)" mode="widthFix"></image>
								<text class="uni-body">{{item.stTitle}}</text>
								<view slot="actions" class="card-actions st-card">
									<view class="card-actions-item">
										<uni-icons type="heart" size="18" color="#999"></uni-icons>
										<text class="card-actions-item-text" style="color: gray;">{{item.stZan}}</text>
									</view>
									<view class="card-actions-item">
										<uni-icons type="star" size="18" color="#999"></uni-icons>
										<text class="card-actions-item-text" style="color: gray;">{{item.stSc}}</text>
									</view>
									<view class="card-actions-item">
										<uni-icons type="trash" size="18" color="#999" @click="todel(index)"></uni-icons>
									</view>
								</view>
				</uni-card>
			</view>
			<view class="st-footer">
				<p><text>没有更多内容了</text></p>
				
			</view>
			<view class="add-st" @click="toAddSt()">
				<image src="../../static/st-add.png" mode="" style="width: 96rpx; height: 96rpx;"></image>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				current:0,
				
				stList:[
				]
			}
		},
		onLoad(){
			this.initList()
		},
		methods: {
			initList(){
				this.request({
					url:"/user-sc/list",
					method:'GET'
				}).then(res=>{
					if(res.code==='1'){
						this.stList = res.data
					}
				}).catch(()=>{
					uni.showToast({
						icon:'error',
						title:'服务异常'
					})
				})
			},
			change(e){
				this.current = e.detail.current
			},
			toAddSt(){
				uni.navigateTo({
					url:"/pages/add-st/add-st"
				})
			},
			toStdetail(id){
				
				uni.navigateTo({
					url:"/pages/st-detail/st-detail?stid="+id
				})
			},
			todel(index){
				//发送请求
				
				var id = this.stList[index].stId
				
				//请求成功
				this.request({
					url:"/user-sc/del",
					method:'GET',
					data:{
						stId:id
					}
				}).then(res=>{
					if(res.code==='1'){
						uni.showToast({
							icon:'success',
							title:'删除成功'
						})
						this.stList = this.stList.filter(item=>{
							return item.stId != id
						})
					}
				}).catch(()=>{
					uni.showToast({
						icon:'error',
						title:'服务异常'
					})
				})
				
			
				
			}
		}
	}
</script>

<style scoped>
.st-content{
	background-color: #f1f1f1f1;
}
.st-main {
	position: absolute;
	top:20rpx;
	width:100%;
	height: 700rpx;
	background-color: #ffffff;
	border-radius: 30rpx;
}
.st-main-header {
	margin-top: 20rpx;
}
.st-card {
	display: flex;
	justify-content: space-around;
}
.st-card view {
	margin-bottom: 10rpx;
}
.st-footer {
	text-align: center;
	margin-bottom: 20rpx;
	width: 100%;
}
.st-footer p{
	font-size: 25rpx;
	color: gray;
	width: 100%;
	margin-bottom: 20rpx;
}
.add-st {
	position: fixed;
	bottom: 100rpx;
	right: 0rpx;
}

</style>
